from utils.other_tools.jsonpath_data_replace import jsonpath_replace
from utils.other_tools.models import TestCase, DependentData


class DependentCase:

    def __init__(self, dependent_yaml_case: TestCase):
        self.__yaml_case = dependent_yaml_case


    def is_dependent(self):
        pass

    def get_dependent_data(self) -> None:
        _dependent_data = DependentData(self.__yaml_case).is_dependent()
        _new_data = None
        # 是否存在依赖
        if _dependent_data is not None and _dependent_data is not False:
            for key, value in _dependent_data.items():
                _change_data = key.split(".")
                yaml_case = self.__yaml_case
                _new_data = jsonpath_replace(change_data=_change_data, key_name='yaml_case')
                _new_data += ' = ' + str(value)
                exec(_new_data)